Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modal):customizability of chart modal #1704

Merged

Conversation

RiyaJethwa
Copy link
Contributor

Updates

  • #1700
  • Addition of headingFormatter, valueFormatter and tableFormatter under modal property in options object.
  • User can now do the following:
    1. customise headers using headingFormatter
    2. format individual column values using valueFormatter
    3. format entire dataset using tableFormatter

Demo screenshot or recording

image

@RiyaJethwa RiyaJethwa requested review from theiliad and a team as code owners December 19, 2023 15:59
Copy link

netlify bot commented Dec 19, 2023

Deploy Preview for carbon-charts-angular ready!

Name Link
🔨 Latest commit b04ce29
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-angular/deploys/65a0dc40a5c7580008407241
😎 Deploy Preview https://deploy-preview-1704--carbon-charts-angular.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 19, 2023

Deploy Preview for carbon-charts-react ready!

Name Link
🔨 Latest commit b04ce29
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-react/deploys/65a0dc4006e1e40008e86598
😎 Deploy Preview https://deploy-preview-1704--carbon-charts-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 19, 2023

Deploy Preview for carbon-charts-core ready!

Name Link
🔨 Latest commit b04ce29
🔍 Latest deploy log https://app.netlify.com/sites/carbon-charts-core/deploys/65a0dc40d19fc700080e1605
😎 Deploy Preview https://deploy-preview-1704--carbon-charts-core.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@RiyaJethwa
Copy link
Contributor Author

I have read the DCO document and I hereby sign the DCO.

const result = [
['Source', 'Target', 'Value'],
const headingLabels = ['Source', 'Target', 'Value']
const tabelData = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the spelling from tabelData to tableData here and on line 22

...displayData.map((datum: any) => [datum['source'], datum['target'], datum['value']])
]

return result
return super.formatTable(headingLabels, tabelData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error - tableData instead of tabelData

get(options, 'bins.rangeLabel') || 'Range',
...binnedStackedData.map(datum => get(datum, `0.${groupMapsTo}`))
]
const tabelData = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

])
]

return result
return super.formatTable(headingLabels, tabelData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

['Group', 'Minimum', 'Q1', 'Median', 'Q3', 'Maximum', 'IQR', 'Outlier(s)'],
...boxplotData.map((datum) => {
const headingLabels = ['Group', 'Minimum', 'Q1', 'Median', 'Q3', 'Maximum', 'IQR', 'Outlier(s)']
const tabelData = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

displayData.forEach((datum: any) => {
if (Array.isArray(datum.children)) {
datum.children.forEach((child: any) => {
result.push([child.name, datum.name, child.value])
tabelData.push([child.name, datum.name, child.value])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

})
} else if (getProperty(datum.name) !== null && getProperty(datum.value)) {
result.push(['–', datum.name, datum.value])
tabelData.push(['–', datum.name, datum.value])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

}
})

return result
return super.formatTable(headingLabels, tabelData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

const result = [
[options.tooltip.wordLabel, 'Group', options.tooltip.valueLabel],
const headingLabels = [options.tooltip.wordLabel, 'Group', options.tooltip.valueLabel]
const tabelData = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

...displayData.map((datum: any) => [
datum[wordMapsTo],
datum[groupMapsTo],
datum[fontSizeMapsTo]
])
]

return result
return super.formatTable(headingLabels, tabelData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename tabelData to tableData

Copy link
Member

@theiliad theiliad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good otherwise, thanks @RiyaJethwa

@@ -46,6 +41,34 @@ export class ChartModel {
this.services = services
}

formatTable(headingLabels, tableData) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we pls update this function to just take an object instead of 2 parameters

e.g. formatTable({ headers: [...], cells: [...] }) this way it's easier to read

@@ -46,6 +41,34 @@ export class ChartModel {
this.services = services
}

formatTable(headingLabels, tableData) {
const options = this.getOptions()
const headingFormatter = getProperty(options, 'modal', 'headingFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this options.tabularRepresentation.headingFormatter, modal seems a bit too generic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this tableHeadingFormatter

formatTable(headingLabels, tableData) {
const options = this.getOptions()
const headingFormatter = getProperty(options, 'modal', 'headingFormatter')
const valueFormatter = getProperty(options, 'modal', 'valueFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this tableCellFormatter

const options = this.getOptions()
const headingFormatter = getProperty(options, 'modal', 'headingFormatter')
const valueFormatter = getProperty(options, 'modal', 'valueFormatter')
const tableFormatter = getProperty(options, 'modal', 'tableFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tableFormatter is a great name for this one

domainValueFormatter = (d: any) => format(d, 'MMM d, yyyy')
}
const result = [
headingFormatter && typeof headingFormatter === 'function'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
headingFormatter && typeof headingFormatter === 'function'
typeof headingFormatter === 'function'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't just checking the type be enough?

@@ -46,6 +41,30 @@ export class ChartModel {
this.services = services
}

formatTable({ headers, cells }) {
const options = this.getOptions()
const tableHeadingFormatter = getProperty(options, 'modal', 'tableHeadingFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tableHeadingFormatter = getProperty(options, 'modal', 'tableHeadingFormatter')
const tableHeadingFormatter = getProperty(options, 'tabularRepModal', 'tableHeadingFormatter')

formatTable({ headers, cells }) {
const options = this.getOptions()
const tableHeadingFormatter = getProperty(options, 'modal', 'tableHeadingFormatter')
const tableCellFormatter = getProperty(options, 'modal', 'tableCellFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tableCellFormatter = getProperty(options, 'modal', 'tableCellFormatter')
const tableCellFormatter = getProperty(options, 'tabularRepModal', 'tableCellFormatter')

const options = this.getOptions()
const tableHeadingFormatter = getProperty(options, 'modal', 'tableHeadingFormatter')
const tableCellFormatter = getProperty(options, 'modal', 'tableCellFormatter')
const tableFormatter = getProperty(options, 'modal', 'tableFormatter')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tableFormatter = getProperty(options, 'modal', 'tableFormatter')
const tableFormatter = getProperty(options, 'tabularRepModal', 'tableFormatter')

@theiliad theiliad merged commit 9462031 into carbon-design-system:master Jan 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants